home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 August / macformat-027.iso / mac / Shareware City / Developers / Oberon⁄F / Manuals / Format (.txt) < prev    next >
Encoding:
Oberon Document  |  1994-06-07  |  8.6 KB  |  113 lines  |  [oODC/obnF]

  1. Documents.StdDocumentDesc
  2. Documents.DocumentDesc
  3. Containers.ViewDesc
  4. Views.ViewDesc
  5. Stores.StoreDesc
  6. Documents.ModelDesc
  7. Containers.ModelDesc
  8. Models.ModelDesc
  9. Stores.ElemDesc
  10. TextViews.StdViewDesc
  11. TextViews.ViewDesc
  12. TextModels.StdModelDesc
  13. TextModels.ModelDesc
  14. TextModels.AttributesDesc
  15. Geneva
  16. TextRulers.StdRulerDesc
  17. TextRulers.RulerDesc
  18. TextRulers.StdStyleDesc
  19. TextRulers.StyleDesc
  20. TextRulers.AttributesDesc
  21. Geneva
  22. Geneva
  23. Geneva
  24. Geneva
  25. Part III
  26. Reference
  27. This section describes the format of the module interface descriptions contained in the next sections. There is one section per public module.
  28. Each section begins with a module definition. A pseudo Oberon notation is used, which lists all exported items of a module, and only those. It begins with the keyword DEFINITION instead of MODULE, export marks are omitted (except read-only marks), and procedure bodies and the module body are left out as well. A type-bound procedure appears in the corresponding record declaration itself.
  29. The hypothetical module "Dictionaries" serves as an example:
  30. DEFINITION Dictionaries;
  31.     CONST maxElems = 32;
  32.     TYPE
  33.         Dictionary = POINTER TO DictionaryDesc;
  34.         DictionaryDesc = RECORD
  35.             elems-: INTEGER;
  36.             PROCEDURE (d: Dictionary) Put (string: ARRAY OF CHAR; VAR key: INTEGER);
  37.             PROCEDURE (d: Dictionary) Get (key: INTEGER; VAR string: ARRAY OF CHAR)
  38.         END;
  39.     VAR someDict: Dictionary;
  40.     PROCEDURE Init;
  41. END Dictionaries.
  42. In an extended record, the inherited procedures are not listed, only the new procedures. The only exception is an inherited function procedure which returns a pointer that is an extension of the one returned by the base procedure (covariant function result).
  43. A module definition is followed by a brief description of the abstraction(s) provided by the module.
  44. This module provides a concrete type Dictionary for the manipulation of string dictionaries.
  45. Then the constants of the module are listed, without their values:
  46. CONST maxElems
  47. Maximum number of elements in a dictionary.
  48. This is followed by the module's types. Record types are not described separately if a pointer type is available:
  49. TYPE Dictionary
  50. Interface
  51. Manages a dictionary of strings, with an integer number as key.
  52. Each type which serves as an interface type is marked as such, as above. An extension of a concrete type is never an interface type. Concrete types are not marked as such.
  53. If the type is an extension of another type, this is marked, e.g. as
  54. Interface, Extension
  55. Base types are not marked as such.
  56. Then the record fields are listed:
  57. elems-: INTEGER    0 <= elems <= maxElems
  58. The number of elements currently in the dictionary.
  59. As in the above example, an invariant over the record field's value may optionally be given.
  60. Then the procedures bound to this type are given:
  61. PROCEDURE (d: Dictionary) Put (string: ARRAY OF CHAR; VAR key: INTEGER)
  62. Interface
  63. For each type-bound procedure, it is specified whether this procedure is interface, empty, default, or normal. An interface procedure may never be called. An empty procedure need never be called by an extending procedure (i.e. through a "super"-call of an "overriding" procedure). A default procedure may be replaced completely by an extending procedure. In this case, the extending procedure must implement the same behavior as the extended procedure. The Oberon/F documentation marks procedures as default procedures if they may be replaced by more efficient, but semantically equivalent implementations. Otherwise, concrete procedures implement some behavior and must always be called by extending procedures. An extension of an empty, a default, or a normal procedure is always marked the same way as its direct base procedure, or as a concrete procedure. Concrete procedures are not marked as such.
  64. Every type which contains one or more interface procedures is an interface type.
  65. For each type-bound procedure, it is specified whether this procedure is an extended procedure, i.e. whether a corresponding procedure already exists for its base type.
  66. An explanation of the procedure's behavior follows:
  67. Put a string into dictionary d, and receive key in return. If the string is already in the dictionary, the same key is returned as when it was inserted first. If the string is not in the dictionary, it is inserted and a value which has not been used before is returned.
  68. After an explanation in plain English, some preconditions for this procedure may be specified. These preconditions are given in a semi-formal notation:
  69. string # ""    20
  70. This means that if the precondition is violated (i.e. if string = ""), the currently executing command is aborted with exception number 20. Instead of a number, the following exceptions may be specified as well:
  71.  invalid index
  72.  type guard check
  73. A second precondition may thus be the following:
  74. string in d OR  d.elems < maxElems    invalid index
  75. After the preconditions, some postconditions may be specified as well:
  76. string in d'
  77.     old key returned
  78. ~(string in d')
  79.     string in d
  80.     d.elems = d.elems' + 1
  81.     new key returned
  82. This postcondition contains two cases, namely what happens if the string is already contained in d, and what happens if the string is not yet contained in d. The conditions are textually aligned to the left, while the respective conclusions are indented. Occasionally, conditions are nested by further indentations.
  83. To refer to values before the operation, an expression is followed by an apostrophe if this is necessary for clarity (i.e. if the value may be changed at all). Thus the expression
  84.     d.elems = d.elems' + 1
  85. means that the value of d.elems has been incremented by one.
  86. Oberon is generally used as syntax for such expressions, although some liberties are taken, e.g. simple auxiliary procedures (which may not be described further) may be used, or expressions like "r.Base().Length()" are used (which are not legal in Oberon).
  87. Function results are generically called "result".
  88. The amount of formalism is kept small. It is attempted to limit formal specifications to few and simple conditions, or to the explanation of particularly subtle situations. It is not intended to specify complete formal semantics of the library, thus the formalism does not replace plain text explanations, examples, or graphical illustrations completely.
  89. However, it is felt that checked preconditions in particular are often helpful even in this incomplete and semi-formal way, both for documentation and for debugging.
  90. PROCEDURE (d: Dictionary) Get (key: INTEGER; VAR string: ARRAY OF CHAR)
  91. Interface
  92. Retrieve a string from the dictionary, by using key. If the value is not found, key is set to the empty string.
  93. key in d
  94.     return corresponding string
  95. ~(key in d)
  96.     return ""
  97. Procedures which are inherited through type extension are usually not listed here. Exceptions are procedures which have changed their semantics. The change in semantics is restricted to having weaker preconditions or stronger postconditions.
  98. After all types, the global variables are listed:
  99. VAR someDict: Dictionary    someDict # NIL
  100. This variable contains a dictionary.
  101. The optional invariant is established by the module body.
  102. Finally, the procedures exported by the module are listed:
  103. PROCEDURE Init (d: Dictionary)
  104. Initializes a dictionary. Any dictionary may be allocated once only.
  105. d not yet initialized    20
  106. In Oberon/F, all procedures whose names start with "Init" may be called only once per object.
  107. TextControllers.StdCtrlDesc
  108. TextControllers.ControllerDesc
  109. Containers.ControllerDesc
  110. Controllers.ControllerDesc
  111. Geneva
  112. Documents.ControllerDesc
  113.